//
// Created by shen on 8/9/2024.
//

#include "PlayerWrapper.h"
#include "AVPlayer.h"

void PlayerWrapper::Init(JNIEnv *jniEnv, jobject obj,  char *url, int playerType, int renderType,
                         jobject surface) {

    switch (playerType) {
        case FFMEDIA_PLAYER:
            mBasePlayer=new AVPlayer();
            break;

        case HWCODEC_PLAYER:
            break;

    }

    if (mBasePlayer) {

        mBasePlayer->init(jniEnv, obj, url, renderType, surface);
    }
}


void PlayerWrapper::UnInit() {
    if(mBasePlayer) {
        mBasePlayer->UnInit();
        delete mBasePlayer;
        mBasePlayer = nullptr;
    }
}


void PlayerWrapper::Play() {
    if (mBasePlayer){

        mBasePlayer->Play();
    }
}

void PlayerWrapper::Stop() {
    if(mBasePlayer) {
        mBasePlayer->Stop();
    }
}
